#include <stdio.h>

size_t Fibonacci_Recursive(size_t n)
{
    if(n==0)
    {
        return 0;
    }
    if(n==1)
    {
        return 1;
    }
    return Fibonacci_Recursive(n-1)+Fibonacci_Recursive(n-2);
}
size_t Fibonacci_Iterative(size_t n)
{
        if(n==0)
        {
            return 0;
        }
        if(n==1)
        {
            return 1;
        }
    size_t i=0;
    size_t a=0;
    size_t b=1;
    size_t c=0;
    for(i=2;i<=n;++i)
    {
            c=a+b;
            a=b;
            b=c;
    }
    return c;
}

void TestFibonacci()
{
    printf("Please enter a number:");
    size_t n=0;
    scanf("%lu",&n);
//    size_t ret=Fibonacci_Recursive(n);//不建议使用递归算法，效率太差
//    printf("ret is %lu\n",ret);
    size_t ret_1=Fibonacci_Iterative(n);
    printf("ret_1 is %lu",ret_1);
}
int main()
{
    TestFibonacci();
}
